package com.yanqu.road.entity.config.goods;

import com.yanqu.road.entity.config.system.NormalWeightItem;
import com.yanqu.road.utils.string.StringUtils;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class GoodsInfo {
	/**
	 * 道具编号
	 */
	private int goodsId;
	/**
	 * 道具类型
	 */
	private int type;
	/**
	 * 道具品质
	 */
	private int quality;
	/**
	 * 道具能否使用
	 */
	private int canUse;
	/**
	 * 叠加上限
	 */
	private int topLimit;
	/**
	 * 排序
	 */
	private int sort;
	/**
	 * 参数数组
	 */
	private String paramStr;
	private List<BigInteger> paramList = new ArrayList<>();

	private String goodsName;

	private String goodsDesc;

	private String icon;

	private String getWay;

	private String extendParam;

	private String resourceParam;

	private boolean hidden;

	private boolean canBagUse;

	private List<NormalWeightItem> weightItemList = new ArrayList<>();

	private int totalWeight;

	private String mailTitle = "";            //邮件辩题
	private String mailContent = "";          //邮件内容

	private int recyclingType;

	/**
	 * 商会福利宝箱大奖id
	 */
	private Set<Integer> unionChestBigRewardIdSet = new HashSet<>();

	//后台用
	private int area;

	public int getGoodsId() {
		return goodsId;
	}

	public void setGoodsId(int goodsId) {
		this.goodsId = goodsId;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public int getQuality() {
		return quality;
	}

	public void setQuality(int quality) {
		this.quality = quality;
	}

	public int getCanUse() {
		return canUse;
	}

	public void setCanUse(int canUse) {
		this.canUse = canUse;
	}

	public int getTopLimit() {
		return topLimit;
	}

	public void setTopLimit(int topLimit) {
		this.topLimit = topLimit;
	}

	public int getSort() {
		return sort;
	}

	public void setSort(int sort) {
		this.sort = sort;
	}

	public String getParamStr() {
		return paramStr;
	}

	public void setParamStr(String paramStr) {
		this.paramStr = paramStr;
	}

	public List<BigInteger> getParamList() {
		return paramList;
	}

	public void setParamList(List<BigInteger> paramList) {
		this.paramList = paramList;
	}

	public String getGoodsName() {
		return goodsName;
	}

	public void setGoodsName(String goodsName) {
		this.goodsName = goodsName;
	}

	public String getGoodsDesc() {
		return goodsDesc;
	}

	public void setGoodsDesc(String goodsDesc) {
		this.goodsDesc = goodsDesc;
	}

	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public String getGetWay() {
		return getWay;
	}

	public void setGetWay(String getWay) {
		this.getWay = getWay;
	}

	public String getExtendParam() {
		return extendParam;
	}

	public void setExtendParam(String extendParam) {
		this.extendParam = extendParam;
	}

	public String getResourceParam() {
		return resourceParam;
	}

	public void setResourceParam(String resourceParam) {
		this.resourceParam = resourceParam;
	}

	public boolean isHidden() {
		return hidden;
	}

	public void setHidden(boolean hidden) {
		this.hidden = hidden;
	}

	public boolean isCanBagUse() {
		return canBagUse;
	}

	public void setCanBagUse(boolean canBagUse) {
		this.canBagUse = canBagUse;
	}

	public List<NormalWeightItem> getWeightItemList() {
        return weightItemList;
    }

    public void setWeightItemList(List<NormalWeightItem> weightItemList) {
        this.weightItemList = weightItemList;
        if(null == weightItemList){
            totalWeight = 0;
        }else {
            int tempWeight = 0;
            for(NormalWeightItem weightItem : weightItemList){
                tempWeight += weightItem.getWeight();
            }
            totalWeight = tempWeight;
        }
    }

    public int getTotalWeight() {
        return totalWeight;
    }

	public String getMailTitle() {
		return mailTitle;
	}

	public void setMailTitle(String mailTitle) {
		this.mailTitle = mailTitle;
	}

	public String getMailContent() {
		return mailContent;
	}

	public void setMailContent(String mailContent) {
		this.mailContent = mailContent;
	}

	public boolean isUnionChestBigReward(int goodsId){
		if (unionChestBigRewardIdSet.isEmpty()){
			synchronized (unionChestBigRewardIdSet){
				if (unionChestBigRewardIdSet.isEmpty()){
					String[] split = this.getExtendParam().split("\\|");
					for (String s : split) {
						String[] split1 = s.split(";");
						if (split1[2].equals("1")) {
							List<Integer> integers = StringUtils.stringToIntegerList(split1[0], "=");
							int itemId = integers.get(0);
							unionChestBigRewardIdSet.add(itemId);
						}
					}
				}
			}
		}

		return unionChestBigRewardIdSet.contains(goodsId);

	}

	public int getRecyclingType() {
		return recyclingType;
	}

	public void setRecyclingType(int recyclingType) {
		this.recyclingType = recyclingType;
	}

	public int getArea() {
		return area;
	}

	public void setArea(int area) {
		this.area = area;
	}
}
